package com.example.mobile2021606176mhq0427;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class parkRVAdapter extends RecyclerView.Adapter<parkRVAdapter.ViewHolder> {
    private List<park> list;
    public parkRVAdapter(List<park> list){this.list=list;}

    static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView p1;
        TextView tvt1,tvt2,tvt3,tvt4,tvt5,tvt6;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvt1=itemView.findViewById(R.id.item_tv_main_t1);
            tvt2=itemView.findViewById(R.id.item_tv_main_t2);
            tvt3=itemView.findViewById(R.id.item_tv_main_t3);
            tvt4=itemView.findViewById(R.id.item_tv_main_t4);
            tvt5=itemView.findViewById(R.id.item_tv_main_t5);
            tvt6=itemView.findViewById(R.id.item_tv_main_t6);
            p1=itemView.findViewById(R.id.item_main_p1);
        }
    }
    @NonNull
    @Override
    public parkRVAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_park,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        park park=list.get(position);
        holder.tvt1.setText(park.getT1());
        holder.tvt2.setText(park.getT2());
        holder.tvt3.setText(park.getT3());
        holder.tvt4.setText(park.getT4());
        holder.tvt5.setText(park.getT5());
        holder.tvt6.setText(park.getT6());
        holder.p1.setImageResource(park.getP1());


    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
